package com.qf.micrograss.upload;

import com.qf.common.minio.utils.MinioUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * --- 缘分让我们相遇乱世以外 ---
 *
 * @author SJY
 * 2025/1/4
 */
@RestController
public class UploadController {

    @Resource
    private MinioUtil minioUtil;

    @PostMapping("/upload")
    public String upload(MultipartFile file) {
        // String path = minioUtil.upload(file);
        String path = null;
        try {
            path = minioUtil.upload(file.getInputStream(), file.getOriginalFilename());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return path;
    }
}
